<?php
/*
	test-simpleurlmapper.php

	Test file to test simpleurlmapper.php.

	@package SimpleUrlMapper
	@version 0.96 beta
	@copyright 2008 Mike Schinkel
	@author Mike Schinkel
	@link http://code.google.com/p/simpleurlmapper/ SimpleUrlMapper
	@license http://www.opensource.org/licenses/bsd-license.php New BSD License

*/
		$path = (isset($_GET['path']) ? $_GET['path'] : 'images/123/crops/4/edit');

		require_once('simpleurlmapper.php');

		$url_mapper = new SimpleUrlMapper();
		$url_mapper->add_variable('image_id',
			array(
				'decription' => 'Positive integer matching a valid ID for an existing image in the media library.',
				'type' => 'integer',
				'validator' => 'validate_image_id',
			));
		$url_mapper->add_variable('crop_no',
			array(
				'decription' => 'Positive integer 1..{n} where {n} is the maximum number of predefined crop sizes required.',
				'type' => 'integer',
				'validator' => array(1,5),
			));
		$url_mapper->add_variable('post_id',
			array(
				'decription' => 'Positive integer matching a valid ID for an existing post.',
				'type' => 'integer',
				'validator' => 'validate_post_id',
			));
		$url_mapper->add_template('edit',
			array(
				'template' => 'images/{image_id}/crops/{crop_no}/edit',
				'action' => 'do_edit_crop',
			));
		$url_mapper->add_template('review',
			array(
				'template' => 'images/{image_id}/crops/review',
				'action' => 'do_review_crops',
			));
		$url_mapper->add_template('crop',
			array(
				'template' => 'images/{image_id}/crops/{crop_no}',
				'action' => 'do_crop',
			));
		$url_mapper->add_template('associate',
			array(
				'template' => 'images/{image_id}/posts/{post_id}',
				'action' => 'do_set_post_association',
			));

		echo '<h1>SimpleUrlMapper ' . SimpleUrlMapper::get_version() . "\r\n</h1><p>";
		$url_mapper->execute($path);
		echo '</p>';

	function do_edit_crop($data) {
		extract($data);
		print "Do Edit Crop #$crop_no for Image ID $image_id\r\n<br/>";
		return;
	}
	/*
		do_review_crops($data)
	*/
	function do_review_crops($data) {
		extract($data);
		print 'Do Review Crops';
		return;
	}
	/*
		do_crop($data)
	*/
	function do_crop($data) {
		extract($data);
		print 'Do Crop';
		return;
	}
	/*
		do_set_post_association($data)
	*/
	function do_set_post_association($data) {
		extract($data);
		print 'Do Set Association';
		return;
	}

	/*
		validate_image_id()
	*/
	function validate_image_id($value,$data) {
		print "Validate Image ID $value\r\n<br>";
		return true;
	}
	/*
		validate_post_id()
	*/
	function validate_post_id($value,$data) {
		print "Validate Post ID $value\r\n<br>";
		return true;
	}

?>
